package cn.net.yto.school.web.sts;

import cn.net.yto.school.dao.dto.CourseDownloadByCourseStsDto;
import cn.net.yto.school.dao.dto.CourseDownloadStsDto;
import cn.net.yto.school.service.StsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
@RequestMapping("/sts/download")
public class StsCourseFileDownloadController {

    @Autowired
    private StsService stsService;


    @RequestMapping(value = "course", method = {RequestMethod.GET})
    public String getCourseFileDownload(HttpServletRequest request, HttpServletResponse response, Model model) {

        List<CourseDownloadStsDto> courseDownloadStsDtos = stsService.stsCourseDownloadCount();

        model.addAttribute("stss", courseDownloadStsDtos);

        return "sts/show_course_file";
    }

    @RequestMapping(value = "clazz2course", method = {RequestMethod.GET})
    public String getCourseFileDownloadByCourse(HttpServletRequest request, HttpServletResponse response, Model model) {

        List<CourseDownloadByCourseStsDto> courseDownloadByCourseStsDtos = stsService.courseDownloadByCourseSts();

        model.addAttribute("stss", courseDownloadByCourseStsDtos);

        return "sts/show_course_file_by_course";
    }
}
